﻿<%@ Page Language="C#" MasterPageFile="../main.master" Inherits="VioletDevelopmentLaboratory.Net.Web.Configuration.VWebConfigManagerPage" %>

<script runat="server">
	protected void CustomErrorsDetailsView_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
	{
		ShowAlert_DetailsView_ItemUpdated(e);
	}






	protected void ErrorsGridView_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
	{
		ErrorsDetailsView.ChangeMode(DetailsViewMode.ReadOnly);
	}
	protected void ErrorsDetailsView_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
	{
		ShowAlert_DetailsView_ItemInserted(e);

		ErrorsGridView.SelectedIndex = -1;
		ErrorsGridView.DataBind();
	}
	protected void ErrorsDetailsView_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
	{
		ShowAlert_DetailsView_ItemUpdated(e);

		ErrorsGridView.SelectedIndex = -1;
		ErrorsGridView.DataBind();
	}
	protected void ErrorsDetailsView_ItemDeleted(object sender, DetailsViewDeletedEventArgs e)
	{
		ShowAlert_DetailsView_ItemDeleted(e);

		ErrorsDetailsView.ChangeMode(DetailsViewMode.Insert);
		
		ErrorsGridView.SelectedIndex = -1;
		ErrorsGridView.DataBind();
	}
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="BodyContentPlaceHolder" runat="server">

	<h2>CustomErrors</h2>

	<div>
		<asp:ObjectDataSource ID="CustomErrorsDetailsViewDataSource" runat="server" 
			SelectMethod="GetCustomErrors" 
			TypeName="VioletDevelopmentLaboratory.Net.Web.Configuration.CustomErrorsSectionManager" 
			UpdateMethod="Modify">
			<UpdateParameters>
				<asp:Parameter Name="mode" Type="Object" />
				<asp:Parameter Name="defaultRedirect" Type="String" />
			</UpdateParameters>
		</asp:ObjectDataSource>
		<fieldset>
			<legend>customErrors</legend>
			<asp:DetailsView ID="CustomErrorsDetailsView" runat="server" AutoGenerateRows="False" 
				CellPadding="5" DataSourceID="CustomErrorsDetailsViewDataSource" 
							onitemupdated="CustomErrorsDetailsView_ItemUpdated" DefaultMode="Edit">
				<Fields>
					<asp:TemplateField HeaderText="Mode">
						<ItemTemplate><%# Eval("Mode") %></ItemTemplate>
						<InsertItemTemplate>
							<asp:DropDownList ID="ModeDropDownList" runat="server" SelectedValue='<%# Bind("Mode") %>'>
								<asp:ListItem>On</asp:ListItem>
								<asp:ListItem>Off</asp:ListItem>
								<asp:ListItem>RemoteOnly</asp:ListItem>
							</asp:DropDownList>
						</InsertItemTemplate>
						<EditItemTemplate>
							<asp:DropDownList ID="ModeDropDownList" runat="server" SelectedValue='<%# Bind("Mode") %>'>
								<asp:ListItem>On</asp:ListItem>
								<asp:ListItem>Off</asp:ListItem>
								<asp:ListItem>RemoteOnly</asp:ListItem>
							</asp:DropDownList>
						</EditItemTemplate>
					</asp:TemplateField>
					<asp:BoundField DataField="DefaultRedirect" HeaderText="DefaultRedirect" 
						SortExpression="DefaultRedirect" />
					<asp:CommandField ButtonType="Button" ShowCancelButton="False" 
						ShowEditButton="True" />
				</Fields>
			</asp:DetailsView>
		</fieldset>
	</div>

	<div style="margin-left : 30px">
		<asp:ObjectDataSource ID="ErrorsDetailsViewDataSource" runat="server" 
			DeleteMethod="RemoveError" InsertMethod="AddError" SelectMethod="GetErrors" 
			TypeName="VioletDevelopmentLaboratory.Net.Web.Configuration.CustomErrorsSectionManager" 
			UpdateMethod="ModifyError">
			<DeleteParameters>
				<asp:Parameter Name="statusCode" Type="String" />
			</DeleteParameters>
			<UpdateParameters>
				<asp:Parameter Name="statusCode" Type="String" />
				<asp:Parameter Name="redirect" Type="String" />
			</UpdateParameters>
			<SelectParameters>
				<asp:ControlParameter ControlID="ErrorsGridView" Name="statusCode" 
					PropertyName="SelectedValue" Type="String" />
			</SelectParameters>
			<InsertParameters>
				<asp:Parameter Name="statusCode" Type="Int32" />
				<asp:Parameter Name="redirect" Type="String" />
			</InsertParameters>
		</asp:ObjectDataSource>
		<asp:ObjectDataSource ID="ErrorsGridViewDataSource" runat="server" 
			SelectMethod="GetErrors" 
			
			TypeName="VioletDevelopmentLaboratory.Net.Web.Configuration.CustomErrorsSectionManager">
		</asp:ObjectDataSource>
		<fieldset>
			<legend>errors</legend>
			<asp:DetailsView ID="ErrorsDetailsView" runat="server" AutoGenerateRows="False" 
				CellPadding="5" DataSourceID="ErrorsDetailsViewDataSource" DefaultMode="Insert" 
				oniteminserted="ErrorsDetailsView_ItemInserted" 
				onitemupdated="ErrorsDetailsView_ItemUpdated" 
				onitemdeleted="ErrorsDetailsView_ItemDeleted" DataKeyNames="StatusCode">
				<Fields>
					<asp:TemplateField HeaderText="StatusCode">
						<ItemTemplate><%# Eval("StatusCode") %></ItemTemplate>
						<InsertItemTemplate>
							<asp:DropDownList ID="StatusCodeDropDownList" runat="server" SelectedValue='<%# Bind("StatusCode") %>'>
								<asp:ListItem>400</asp:ListItem>
								<asp:ListItem>401</asp:ListItem>
								<asp:ListItem>403</asp:ListItem>
								<asp:ListItem>404</asp:ListItem>
								<asp:ListItem>405</asp:ListItem>
								<asp:ListItem>406</asp:ListItem>
								<asp:ListItem>407</asp:ListItem>
								<asp:ListItem>410</asp:ListItem>
								<asp:ListItem>412</asp:ListItem>
								<asp:ListItem>414</asp:ListItem>
								<asp:ListItem>415</asp:ListItem>
								<asp:ListItem>500</asp:ListItem>
								<asp:ListItem>501</asp:ListItem>
								<asp:ListItem>502</asp:ListItem>
							</asp:DropDownList>
						</InsertItemTemplate>
						<EditItemTemplate>
							<asp:Label ID="StatusCodeLabel" runat="server" Text='<%# Bind("StatusCode") %>' />
						</EditItemTemplate>
					</asp:TemplateField>
					<asp:BoundField DataField="Redirect" HeaderText="Redirect" 
						SortExpression="Redirect" />
					<asp:CommandField ButtonType="Button" ShowDeleteButton="True" 
						ShowEditButton="True" ShowInsertButton="True" />
				</Fields>
			</asp:DetailsView>
			<asp:GridView ID="ErrorsGridView" runat="server" AutoGenerateColumns="False" 
				CellPadding="5" DataKeyNames="StatusCode" 
				DataSourceID="ErrorsGridViewDataSource" 
				onselectedindexchanging="ErrorsGridView_SelectedIndexChanging">
				<Columns>
					<asp:CommandField ShowSelectButton="True" />
					<asp:BoundField DataField="StatusCode" HeaderText="StatusCode" 
						SortExpression="StatusCode" />
					<asp:BoundField DataField="Redirect" HeaderText="Redirect" 
						SortExpression="Redirect" />
				</Columns>
				<SelectedRowStyle BackColor="SkyBlue" />
			</asp:GridView>
		</fieldset>
	</div>
</asp:Content>